const Service = require("egg").Service;

class Chapterservice extends Service {

   
    // 查找章节
    async getChapterDetail(id) {
        try {
            const chapter = await this.app.model.Chapter.findOne({
                where: {
                    id
                }
            })
            return chapter
        } catch (error) {
            return null
        }
    }
    // 添加
    async postChapterDetail(id,chapter) {
        try {
            let chapterList = this.app.model.Chapter.create({
                id,
                title:chapter.title,
                md_text:chapter.md_text,
                html_text:chapter.html_text
            })
            console.log("~~~~~~~~~~~~~~~~~~~~~~~~~",chapterList);
            return chapterList
        } catch (error) {
            return null
        }
    }
} 

module.exports = Chapterservice;